#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: node06_field_calculation.py 
@version:
@time: 2022/05/18 
"""
# 05
from TapClientCore.T04_logic.Dag02.node.operate_node.node08_field_rename import FieldRenameNode


class FieldCalculation(FieldRenameNode):
    """
[
          {
            "tableName": "AA",
            "field": "column_1",
            "scriptType": "js",
            "script": "record",
            "id": "6283cd914f15a8260b44ebef",
            "type": "Long",
            "primary_key_position": 0,
            "label": "column_1",
            "field_name": "column_1"
          },
          {
            "tableName": "AA",
            "field": "column_2",
            "scriptType": "js",
            "script": "1",
            "id": "6283cd914f15a8260b44ebf0",
            "type": "Long",
            "primary_key_position": 0,
            "label": "column_2",
            "field_name": "column_2"
          },
          {
            "tableName": "AA",
            "field": "column_3",
            "scriptType": "js",
            "script": " record.isTrue ? true : false",
            "id": "6283cd914f15a8260b44ebf1",
            "type": "Long",
            "primary_key_position": 0,
            "label": "column_3",
            "field_name": "column_3"
          }
        ]
"""
    def generate_node(self, scripts):
        node = {
            "id": self.newId,
            "name": "自动化-字段计算",
            "type": "field_calc_processor",
            "attrs": {
                "position": [
                    -500,
                    200
                ]
            },
            "scripts": scripts
        }
        self.node = node
